package com.lzb.watermarkcamera.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.watermarkcamera.R;
import com.lzb.watermarkcamera.basic.ProviderMultiAdapter;

import java.text.SimpleDateFormat;


public class PictureReportAdapter extends ProviderMultiAdapter<String> {

    public PictureReportAdapter() {
        addItemProvider(new PictureReportProvider());
    }

    private class PictureReportProvider extends BaseItemProvider<String> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_picture_report;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, String bean) {
            Glide.with(baseViewHolder.itemView).load(bean).into((ImageView) baseViewHolder.getView(R.id.ivPictureReportItemImg));
            long mill = FileUtils.getFileLastModified(bean);
            baseViewHolder.setText(R.id.tvPictureReportItemDate, TimeUtils.millis2String(mill, new SimpleDateFormat("yyyy-MM-dd")));
            baseViewHolder.setText(R.id.tvPictureReportItemTime, TimeUtils.millis2String(mill, new SimpleDateFormat("HH:mm:ss")));
        }
    }

}
